#include "userMain.h"
#include "userClockTimerTick.h"

//#define USER_CLOCK_TEST
void userClockMainTickTestFunc(void);
void userClockSubTickTestFunc(void);

uint8_t userDelayCnt2;
void userClockMainTickTestFunc(void)
{
#ifdef	USER_CLOCK_TEST
	static uint8_t TestFlag = 0;
	if(TestFlag)
	{
		TestFlag = 0;
		GPIO_SetBits(GPIOA,GPIO_Pin_0);
	}
	else
	{	
		TestFlag = 1;
		GPIO_ResetBits(GPIOA,GPIO_Pin_0);
        }
	_NOP;
#endif
}

void userClockSubTickTestFunc(void)
{
#ifdef	USER_CLOCK_TEST
	static uint8_t TestFlagB = 0;
	if(TestFlagB)
	{
		TestFlagB = 0;
		GPIO_SetBits(GPIOA,GPIO_Pin_1);
	}
	else
	{	
		TestFlagB = 1;
		GPIO_ResetBits(GPIOA,GPIO_Pin_1);
	}
	_NOP;
#endif
}

uint32_t userCnt;
extern uint8_t userSystemTestFlag;
void userClockMainTickFunc(void)
{
    userCnt = TIM3->CNT;
    _NOP;
    userClockMainTickTestFunc();
    AKeyMarkTickFunc(1);
    BKeyMarkTickFunc(1);
    userIRreleaseTickFunc();
    userKeypadScanFunc();
}
uint8_t userDelayCnt = 0;
void userClockSubTickFunc(void)
{
    userClockSubTickTestFunc();
    userIRreleaseFunc();
    userReportTickSHT20();
    if(userSystemTestFlag==0)
    userGetDataFromBMA253Func();
    userDelayCnt--;
    userLed1BlinkTick();
    userLed2BlinkTick();
    userLed4BlinkTick();
    userLed5BlinkTick();
    userResetKeyTick();
}

void userDelay10ms(uint8_t delayCnt)
{
    userDelayCnt = delayCnt;
    while(userDelayCnt != 0)
    {
        _NOP;
    }
}

void userDelay2ms(uint8_t delayCnt2)
{
    userDelayCnt2 = delayCnt2;
    while(userDelayCnt2 != 0)
    {
        _NOP;
    }
}


/*****************END OF FILE****************/
